package com.hotel.service;

import com.hotel.repository.ExtendedRepository;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("extendedService")
public class ExtendedService {
    private final ExtendedRepository repository;

    public ExtendedService() {
        this.repository = new ExtendedRepository();
    }

    public Map<String, Object> getDashboardOverview() {
        return repository.getDashboardOverview();
    }

    public List<Map<String, Object>> getRoomStats(Map<String, Object> params) {
        String room_type;
        String startDate;
        String endDate;
        if(params.get("room_type") != null) {room_type=params.get("room_type").toString();}
        else room_type="";
        if(params.get("startDate") != null){startDate=params.get("startDate").toString();}
        else startDate="";
        if(params.get("endDate") != null){endDate=params.get("endDate").toString();}
        else endDate="";

        return repository.getRoomStats(room_type, startDate, endDate);
    }

    public List<Map<String, Object>> getAllRoomStats() {
        return repository.getAllRoomStats();
    }

    public List<Map<String, Object>> getConsumptionStats(Map<String, Object> params) {
        String item_name;
        String startDate;
        String endDate;
        if(params.get("item_name") != null) {item_name=params.get("item_name").toString();}
        else item_name="";
        if(params.get("startDate") != null){startDate=params.get("startDate").toString();}
        else startDate="";
        if(params.get("endDate") != null){endDate=params.get("endDate").toString();}
        else endDate="";
        return repository.getConsumptionStats(item_name, startDate, endDate);
    }
    public List<Map<String, Object>> getAllConsumptionStats() {
        return repository.getAllConsumptionStats();
    }
}
